<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    
<%@ page import="edu.itla.medifacil.persistence.enums.Attribute, java.util.HashMap;" %>

<% HashMap<Integer, String> patientAttributes = (HashMap<Integer, String>)request.getSession().getAttribute("patientAttributes"); %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
	<link rel="stylesheet" href="../css/style.css" />
	
	<% 
		if( request.getSession().getAttribute("patient") == null ) 
			response.sendRedirect("/MediFacil/Patients.do"); 
	%>
	
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
	<title>Paciente: ${patient.name} ${patient.lastName}</title>
</head>
<body>
	<jsp:include page="../navigation/header.jsp" >
		<jsp:param value="patients" name="active"/>
	</jsp:include>

	<div id="container">
		<form class="centered" id="patientForm" method="POST" action="/MediFacil/Patients.do">
			<fieldset id="personalInfo">
				<legend>Datos Personales</legend>
				
				<% 
					String picture = ""; 
					if( patientAttributes.get(Attribute.FOTO.getId()) != null ){
						picture = ".." + patientAttributes.get(Attribute.FOTO.getId()); 
					}
					if( picture.equals("..") ) picture = "../img/unknown.png";
				%>
					<div class="floatR">
						<img width="50" height="50" src="<%= picture %>">
					</div>
				
				<div class="input text required duplexInput">
					<label for="firstname">Nombre</label>
					<input readonly="true" type="text" id="firstname" name="name" value="${patient.name}"/>
				</div>
				
				<div class="input text required duplexInput">
					<label for="lastname">Apellido</label>
					<input readonly="true" type="text" id="lastname" name="lastname" value="${patient.lastName}" />
				</div>
				
				<div class="clear"></div>
				
				<div class="input text required duplexInput">
					<label for="identification">Identificaci&oacute;n</label>
					<input readonly="true" type="text" id="identification" name="identification" value="${patient.identification}"/>
				</div>
				
				
				
				<div class="calendar required duplexInput" id="fechaNacimiento">
					<label for="birthdate">Fecha de Nacimiento</label>
					<input readonly="true" autocomplete="off" id="birthdate" name="attributes.<%= Attribute.FECHA_NACIMIENTO.getId() %>" value="<%= patientAttributes.get(Attribute.FECHA_NACIMIENTO.getId()) == null ? "" : patientAttributes.get(Attribute.FECHA_NACIMIENTO.getId()) %>"/>
				</div>
				
				<div class="input textarea">
					<label for="alergies">Alergias</label>
					<textarea readonly="true" id="alergies" name="attributes.<%= Attribute.ALERGIAS.getId() %>"><%= patientAttributes.get(Attribute.ALERGIAS.getId()) == null ? "" : patientAttributes.get(Attribute.ALERGIAS.getId()) %></textarea>
				</div>
				
				<div class="input checkbox">
					<label for="smoke">Fumador</label>
					<input disabled="true" <% if( patientAttributes.get(Attribute.ES_FUMADOR.getId()) != null ){ %> checked="true" <% } %> id="smoke" type="checkbox" name="attributes.<%= Attribute.ES_FUMADOR.getId() %>" />
				</div>
			</fieldset>
			
			<fieldset id="contactInfo">
				<legend>Datos de Contacto</legend>
				
				<div class="input input">
					<label for="tel">T&eacute;lefono</label>
					<input readonly="true" id="tel" type="text" name="attributes.<%= Attribute.TELEFONO.getId() %>" value="<%= patientAttributes.get(Attribute.TELEFONO.getId()) == null ? "" : patientAttributes.get(Attribute.TELEFONO.getId()) %>"/>
				</div>
				
				<div class="input input">
					<label for="cel">Celular</label>
					<input readonly="true" id="cel" type="text" name="attributes.<%= Attribute.CELULAR.getId() %>" value="<%= patientAttributes.get(Attribute.CELULAR.getId()) == null ? "" : patientAttributes.get(Attribute.CELULAR.getId()) %>"/>
				</div>
				
				<div class="input textarea">
					<label for="direction">Direcci&oacute;n</label>
					<textarea readonly="true" id="direction" name="attributes.<%= Attribute.DIRECCION.getId() %>"><%= patientAttributes.get(Attribute.FECHA_NACIMIENTO.getId()) == null ? "" : patientAttributes.get(Attribute.DIRECCION.getId()) %></textarea>
				</div>
			</fieldset>
			
		</form> 
		<button class="action" onclick="window.location='edit.jsp'" type="button">Editar</button>
	</div>
	
	<jsp:include page="../navigation/copyright.html" />
</body>
</html>